package com.gome.axwl.aoc.web.controller.settleMananger;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.anxl.sso.client.api.Account;
import com.gome.axwl.aoc.entity.dto.AmAuditSettingDto;
import com.gome.axwl.aoc.entity.dto.PageResultDto;
import com.gome.axwl.aoc.facade.AuditSettingFacade;
import com.gome.commons.core.ResultData;

/**
 * 项目名称：gome-axwl-aoc-web
 * 类名称：AuditSettingController
 * 类描述：
 * @Author：John Li
 * 创建时间：2018年7月16日16:07:16
 */
@Api(tags = "默认审核配置")
@RestController
@RequestMapping(value = "/auditSetting")
public class AuditSettingController {

    private final static Logger log = LoggerFactory.getLogger(AuditSettingController.class);

    @Autowired
    AuditSettingFacade auditSettingFacade;

    @ApiOperation(value = "默认权限配置列表", notes = "development by John Li")
    @ResponseBody
    @RequestMapping(value = "/getAuditSettingList", method = RequestMethod.POST)
    public ResultData<PageResultDto<AmAuditSettingDto>> getAuditSettingList(@RequestBody AmAuditSettingDto auditSettingDto, HttpServletRequest request) {
        log.info("调用AuditSettingController.getList(查询app版本管理列表),参数为:" + auditSettingDto.toString());
        return auditSettingFacade.getAuditSettingList(auditSettingDto);
    }

    @ApiOperation(value = "删除默认权限配置", notes = "development by John Li")
    @ApiImplicitParam(name = "defaultId", value = "defaultId", paramType = "query", dataType = "int", required = true)
    @RequestMapping(value = "/delAuditSetting", method = RequestMethod.POST)
    public ResultData delAuditSetting(@RequestBody AmAuditSettingDto amAuditSettingDto, HttpServletRequest request) {
        log.info("调用AuditSettingController.delAuditSetting(删除默认权限配置),参数为:" + amAuditSettingDto.toString());
        return auditSettingFacade.deleteAuditSetting(amAuditSettingDto.getDefaultId());
    }

    @ApiOperation(value = "修改默认权限配置", notes = "development by John Li")
    @ApiImplicitParam(name = "id", value = "id", paramType = "query", dataType = "int", required = true)
    @RequestMapping(value = "/updateAuditSetting", method = RequestMethod.POST)
    public ResultData updateAuditSetting(@RequestBody AmAuditSettingDto amAuditSettingDto, HttpServletRequest request) {
        log.info("调用AuditSettingController.updateAuditSetting(修改默认权限配置),参数为:" + amAuditSettingDto.toString());
        return auditSettingFacade.updateAuditSetting(amAuditSettingDto);
    }

    @ApiOperation(value = "新增默认权限配置", notes = "development by John Li")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "auditUser", value = "新增审核设置审核人", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "defaultType", value = "新增审核设置权限类型", paramType = "query", dataType = "Integer", required = true),
    })
    @RequestMapping(value = "/addAuditSetting", method = RequestMethod.POST)
    public ResultData addAuditSetting(@RequestBody AmAuditSettingDto amAuditSettingDto, HttpServletRequest request) {
        log.info("调用AuditSettingController.addAuditSetting(新增默认权限配置),参数为:" + amAuditSettingDto.toString());
        return auditSettingFacade.addAuditSetting(amAuditSettingDto);
    }

    /**
     * 上传apk文件
     *
     * @param keyword
     * @param request
     * @return
     */
    @ApiOperation(value = "筛选审核人员列表", notes = "development by John Li")
    @RequestMapping(value = "/filterAuditUserList", method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "筛选关键字", paramType = "query", dataType = "String", required = true),
    })
    public ResultData filterAuditUserList(@RequestParam(value = "keyword") String keyword, HttpServletRequest request) {
        log.info("调用AuditSettingController.filterAuditUserList(筛选审核人员列表),参数为:" + keyword);
        log.warn("筛选审核人员列表，关键字.");
        return auditSettingFacade.filterAuditUserList(keyword);
    }
    
    @ApiOperation(value = "用户查询下拉")
    @GetMapping("/queryAccountByKeyword")
    @ApiImplicitParams({ @ApiImplicitParam(name = "keyword", paramType = "query", value = "关键字, 可以是员工账号或是员工姓名", required = false) })
    @ResponseBody
    public ResultData<List<Account>> queryAccountByKeyword(@RequestParam("keyword") String keyword) {
        return ResultData.newResultData(auditSettingFacade.queryAccountByKeyword(keyword));
    }


}
